<?php
/*Problem Domain
To create a class that represents the Relationship between User and Session class.
*/

/*
UserSession is new UserSession(int, int, int, String, String)
- interp. new UserSession(user_id, sess_id, status, reason) represents the relationship between User and TrainingSession class where
	- id is the unique id of the UserSession mapping 
	- user_id is the user_id of user from User class.
	- sess_id is the sess_id of the TrainingSession class. 
	- status is one of
		- 'accepted' inidicates that the trainee has accepted the assigned session.
		- 'rejected' indicates that the trainee has rejected the assigned session.
		- 'pending' indicates that the trainee has yet to give his/her decision.
	- reason is one of
		- null indicates that either the trainee has the accepted/pending decision.
		- is the reason given for rejecting the session.

- Example.
$usr1 = new User("mohsin.sayyed@springcomputing.in", "******", "trainee"); 
$usr3 = new User("abhijeet.majgaonkar@springcomputing.in", "******", "trainee");

$sess1 = new TrainingSession("phpsession", "ketul", date("2015-02-08 11:14:15.638276"), Session.AVALIABLE, 'arrays,functions');
$sess2 = new TrainingSession("webuisession", "piyush", date("2015-01-01 10:00:00"), Session.AVAILABLE);

$us1 = new UserSession($usr1->getUserId(), $sess1->getSessionId(), UserSession.PENDING); //initialy admin has assigned mohsin for php session
$us3 = new UserSession($usr1->getUserId(), $sess2->getSessionId(), UserSession.PENDING); //initialy admin has assigned mohsin for webui
$us1->setStatus(UserSession.REJECTED); //mohsin has accepted the assigned session
$us3->setReason('sorry a lot of php assignments to complete');

$us2 = new UserSession($usr3->getUserId(), $sess2->getSessionId(), UserSession.PENDING);//initialy admin has assigned abhijeet for webui 
$us2->setStatus(UserSession.ACCEPTED); //Abhijeet has accepted the assigned session

$sess2->setStatus(TrainingSession::POSTPONED);       //webui session is postponed to
$sess2->setPostDateTime(date("2015-01-08 10:00:00")); // date : 2015-01-08 at 10:00:00

$us2->setStatus(UserSession.REJECTED);
$us2->setReason('sorry i am on leave on 2015-01-08');

- Template.
function fn-for-UserSession()
{
	...$this->id;
	...$this->user_id;
	...$this->sess_id;
	...$this->status;
	...$this->reason;
}   
*/
include_once 'User.php';
include_once 'TrainingSession.php';

class UserSession 
{
	private $id;
	private $user_id;
	private $sess_id;
	private $status;
	private $_reason;

	const ACCEPTED = 'accepted';
	const REJECTED = 'rejected';
	const PENDING  = 'pending';

	/*int, int
	pupose. To initialize the newly created UserSession*/
	public function __construct($user_id, $sess_id, $status = self::PENDING, $_reason = null, $id = null)
	{
		$this->id	= $id;
		$this->user_id 	= $user_id;
		$this->sess_id 	= $sess_id;
		$this->status 	= $status;
		$this->_reason 	= $_reason;
	}

	/*void -> int
        purpose. produces the ID of the current UserSession*/
        public function getId()
        {
                return $this->id;
        }

        /*int -> void
        purpose. sets the given ID for the current UserSession*/
        public function setId($id)
        {
                $this->id = $id;
        }

	/*void -> int
        purpose. produces the user ID of the current UserSession*/
        public function getUserId()
        {
                return $this->user_id;
        }

        /*int -> void
        purpose. sets the given user ID for the current UserSession*/
        public function setUserId($user_id)
        {
                $this->user_id = $user_id;
        }

	/*void -> int
        purpose. produces the session ID of the current UserSession*/
        public function getSessionId()
        {
                return $this->sess_id;
        }

        /*int -> void
        purpose. sets the given session ID for the current UserSession*/
        public function setSessionId($sess_id)
        {
                $this->sess_id = $sess_id;
        }


        /*void -> String
        purpose. produces the status of the current assigned Session*/
        public function getStatus()
        {
                return $this->status;
        }

        /*String -> void
        purpose. sets the given status for the current assigned Session*/
        public function setStatus($status)
        {
                $this->status = $status;
        }

	/*void -> String
        purpose. produces the reason for rejecting the assigned Session*/
        public function getReason()
        {
                return $this->_reason;
        }

        /*String -> void
        purpose. sets the given reason for rejecting the assigned Session*/
        public function setReason($_reason)
        {
                $this->_reason = $_reason;
        }
}

?>
